@extends('layouts.console_header')

@section('title', '角色管理')

@section('resources')
    @parent
    <style>
        table{margin-top: 50px;}
        table tr td{width: 100px;height: 50px;}
    </style>
@endsection

@section('content')
<section class="user_list">
    <div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
        <p class="fz_14 account_title fl" style="border: none;"><span style="color: #7f7f7f;">
        <a href="/console/index">首页</a>>用户后台管理></span><span class="co_violet">角色管理</span></p>
        <a href="/console/admin/account/auth/refresh?cityid={{$cityid}}"><p class="fr tc back_btn">刷新权限</p></a>
        <a href="/console/admin/role/add?cityid={{$cityid}}"><p class="fr tc back_btn">+新增</p></a>
    </div>
    <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                <th>角色名称</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach($lists as $list)
                <tr>
                    <td>{{$list['roleid']}}</td>
                    <td>{{$list['rolename']}}</td>
                    <td>{{date('Y-m-d H:i', strtotime($list['created_at']))}}</td>
                    <td><a href="/console/admin/role/get?cityid={{$cityid}}&roleid={{$list['roleid']}}" style="color: #9955c6;">修改</a>&nbsp;&nbsp;
                    <a style="color: red;" href="" onclick="delete_role({{$list['roleid']}})">删除</a></td>
                </tr>
            @endforeach
        </tbody>
    </table>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
        function delete_role(roleid) {
            var cityid = '{{$cityid}}';
            var isconfirm = confirm("确定删除该角色？");
            if(isconfirm) {
                $.ajax({
                    url : '/console/admin/role/delete',
                    data:{cityid:cityid, roleid:roleid},
                    dataType:'json',
                    type:'post',
                    success:function(data){
                        if(data.status == 'success') {
                            location.reload();
                        }
                    }
                });
            }
        }
    </script>
@endsection